package com.item.news.config;

import com.item.news.runnable.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * @ClassName NewsSchedulingConfig
 * @Description TODO
 * @Author WangDong
 * @Date 2019/2/14 13:23
 * @Version 1.0
 **/
@Configuration
@EnableScheduling
public class NewsSchedulingConfig {

    @Scheduled(fixedRate = 1000*120)
    public void openScheduling(){
        System.out.println("这是获取得数据："+new JedisConfig().getJedis().get("w3ckey"));
        start();
    }

    public void start(){
        //头条
        new Thread(new Top_newsRunnable(new JedisConfig().getJedis())).start();
        //其他
        String[] ohterUrl={"http://sd.news.163.com/","http://news.163.com/domestic/","http://news.163.com/world/","http://ent.163.com/movie/","http://news.163.com/air/"};
        String[] ohterName={"shandong","guonei","guoji","dianying","hangkong"};

        for (int i=0;i<ohterUrl.length;i++){
            new Thread(new Other_newsRunnable(new JedisConfig().getJedis(),ohterUrl[i],ohterName[i])).start();
        }
        //山东
        String[] sdUrl={"http://bendi.news.163.com/shandong/special/jnjk/","http://bendi.news.163.com/shandong/special/jnly/","http://bendi.news.163.com/shandong/special/jnjy/"};
        String[] sdName={"jiankang","lvyou","jiaoyv"};

        for (int i=0;i<sdUrl.length;i++){
            new Thread(new Sd_newsRunnable(new JedisConfig().getJedis(),sdUrl[i],sdName[i])).start();
        }
        //娱乐
        new Thread(new Yl_newsRunnable(new JedisConfig().getJedis(),"http://ent.163.com/special/star_news/")).start();
    }



}
